<?php
require_once 'config21.php';
if (!isset($_SESSION['userid'])) {
    header("Location: login21.php");
    exit;
}
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add_introduce'])) {
    $name=$_POST['name'];
    $anothername=$_POST['anothername'];
    $intro=$_POST['intro'];
    $datetime=date("Y-m-d H:i:s");  // 获取系统时间
    // echo $intro. "<br>";
    $sql="INSERT INTO introduce (name,anothername,intro,datetime)
    VALUE('$name','$anothername','$intro','$datetime')";
    // echo $sql;
    if ($conn->query($sql) === TRUE) {
        header("Location: list_introduce21.php");
        exit;
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加详细介绍</title>
    <link rel="stylesheet" href="style21.css">
</head>
<body>
    <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
        <table width="400" border="1">
            <tbody>
                <tr>
                    <td colspan="2">详细介绍</td>
                </tr>
                <tr>
                    <td>鸟名</td>
                    <td><input type="text" name="name" id="name"></td>
                </tr>
                <tr>
                    <td>别名</td>
                    <td><input type="text" name="anothername" id="anothername"></td>
                </tr>
                <tr>
                    <td>详细介绍</td>
                    <td><textarea name="intro" id="intro"></textarea></td>
                </tr>
                <tr>
                    <td colspan="2" align="2">
                        <input type="submit" name="add_introduce" value="添加">
                        <input type="reset" name="reset" id="reset" value="重置">
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</body>
</html>